package top.kaoshanji.p1ch03a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.nio.ByteBuffer;

/**
 * 代码清单 p1ch03a-03：ByteBuffer类的使用示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/5 19:44
 */
public class ByteBufferExample01 {

    private static final Logger logger = LogManager.getLogger(ByteBufferExample01.class);

    public static void main(String[] args) {
        logger.info("...代码清单 p1ch03a-03：ByteBuffer类的使用示例...");

        ByteBuffer buffer = ByteBuffer.allocate(32); // 创建ByteBuffer的一种方式
        buffer.put((byte) 1);
        buffer.put(new byte[3]);
        buffer.putChar('A');
        buffer.putFloat(0.0f);
        buffer.putLong(10, 100L);

        System.out.println(buffer.getChar(4));
        System.out.println(buffer.remaining());

    }


}
